<?php 
	
	define('CONFIG_PATH', '../config.php');
	include '../function.php';
	include './Onload.class.php';
	// if($_FILES){
	// 	$key = key($_FILES);
	// 	// var_dump($_FILES);exit;
	// 	if(!is_array($_FILES[$key]['tmp_name'])){
	// 			Upload($_FILES[$key]['tmp_name']);
	// 	}else{
	// 		foreach ($_FILES[$key]['tmp_name'] as $value) {
				
	// 			Upload($value);
	// 		}
	// 	}

	// }
	// function Upload($tmpPath)
	// {
	// 	if(is_uploaded_file($tmpPath)){
	// 		$dir = './Upload/';

	// 		!is_dir($dir)? mkdir($dir,777,true) : '' ;

	// 		$path = $dir.uniqid().".jpg";

	// 		move_uploaded_file($tmpPath,$path);
	// 	}
	
	// }

	if($_FILES){
		$config = array(
		'path'=>'./Upload/',
		'size'=>'500000',
		'type'=>array('.png','.gif','.jpg'),
		);

		$obj = new Onload($config);
		$obj->save();
	}

	
	// var_dump ($obj);


	$files = glob('./Upload/*');
	// echo count($files);


	$num = 4;

	$total = ceil(count($files)/$num);

	$files = array_chunk($files,$num);


	if(!isset($_GET['p'])){
		$p =1;
		// 默认显示第一页
	}else{
		$p =$_GET['p'];
	}
	$files= $files[$p-1];
	include './onload.html';




 ?>


